package org.xa3apm.vote.bean;

import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

import org.xa3apm.vote.hibernate.bean.PartyBean;
import org.xa3apm.vote.hibernate.entities.Party;

@ManagedBean(name="party")
@SessionScoped
public class PartyRegistrationBean {
	@EJB
	private PartyBean partyBean;
	private String name;
	/**
	 * @return the party
	 */
	public String register(){
		try{
			Party party = new Party();
			party.setName(name);
			partyBean.save(party);
			return "saveSuccess";
		} catch (Exception e) {
			return "SaveFailed";
		}
	}
	/**
	 * @return the name
	 */
	public final String getName() {
		return name;
	}
	/**
	 * @param name the name to set
	 */
	public final void setName(String name) {
		this.name = name;
	}
}
